package common;

import java.io.Serializable;

/**
 * This class represents a question that appears in automatic exams
 *
 */
public class Question implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6000201961858810442L;
	
	private int id;
	private String question;
	private String[] answers;
	private int correctAnswer;
	private String notes;
	private String teacherName;
	private int teacherId;
	private String subjectName;
	private int points;

	/**
	 * Default constructor
	 */
	public Question() {
		
	}

	/**
	 * ID getter
	 * @return
	 */
	public int getId() {
		return id;
	}
	

	/**
	 * ID setter
	 * @param id Question ID
	 */
	public void setId(int id) {
		if (id > 999 && id < 100000)
			this.id = id;
	}
	
	/**
	 * Question getter
	 * @return Question string
	 */
	public String getQuestion() {
		return question;
	}
	
	/**
	 * Question setter
	 * set only if length > 0
	 * @param question Question to set
	 */
	public void setQuestion(String question) {
		if(question.length()>0)
		this.question = question;
	}

	/**
	 * Get answers array
	 * @return Answers array
	 */
	public String[] getAnswers() {
		return answers;
	}

	/**
	 * Answers setter
	 * @param answers Answers array
	 */
	public void setAnswers(String[] answers) {
		if(answers.length == 4 && answers[0].length()>0 && answers[1].length()>0  && answers[2].length()>0 && answers[3].length()>0)
		this.answers = answers;
	}

	/**
	 * Correct answer number getter
	 * @return
	 */
	public int getCorrectAnswer() {
		return correctAnswer;
	}
	
	/**
	 * Correct answer setter
	 * @param correctAnswer Correct answer index
	 */
	public void setCorrectAnswer(int correctAnswer) {
		if(correctAnswer>0 && correctAnswer<5)
		this.correctAnswer = correctAnswer;
	}
	
	/**
	 * Notes getter
	 * @return Notes
	 */
	public String getNotes() {
		return notes;
	}
	
	/**
	 * Notes setter
	 * @param notes Notes to set
	 */
	public void setNotes(String notes) {
		this.notes = notes;
	}
	
	/**
	 * Teacher's Name creator
	 * @return Teacher's name
	 */
	public String getTeacherName() {
		return teacherName;
	}
	
	/**
	 * Teacher's Name setter
	 * @param teacherName Teacher's name
	 */
	public void setTeacherName(String teacherName) {
		this.teacherName = teacherName;
	}
	
	/**
	 * Subject ID getter
	 * @return Subject ID
	 */
	public int getSubject(){
		return id/1000;
	}
	
	/**
	 * Question ID getter
	 * @return Question ID
	 */
	public int getQuestionID(){
		return id%1000;
	}
	
	/**
	 * Teacher's ID getter
	 * @return
	 */
	public int getTeacherId() {
		return teacherId;
	}
	
	/**
	 * Teacher's ID setter
	 * @param teacherId Teacher ID
	 */
	public void setTeacherId(int teacherId) {
		if(teacherId>0)
		this.teacherId = teacherId;
	}

	/**
	 * Subject name getter
	 * @return
	 */
	public String getSubjectName() {
		return subjectName;
	}

	/**
	 * Subject name setter
	 * @param subjectName Name of the subject
	 */
	public void setSubjectName(String subjectName) {
		this.subjectName = subjectName;
	}
	
	/**
	 * Points getter
	 * @return Points per question
	 */

	public int getPoints() {
		return points;
	}
	
	/**
	 * Points setter
	 * @param points Question points
	 */
	public void setPoints(int points) {
		if(points>0 && points<101)
		this.points = points;
	}
}
